package ReadMP3Files;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.*;
public class ReadMP3Files {
    private Player player;
    private String filename;
    public ReadMP3Files(String filename) {
        this.filename = filename;
    }
    public void stop() {
        if (player != null)
            player.close();
    }
    public void play() {
        try {
            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(filename));
            player = new Player(bis);
        } catch (FileNotFoundException | JavaLayerException ex) {
            System.out.println(ex);
        }
        new Thread(new Runnable() {
        @Override
        public void run() {
                try {
                    player.play();
                } catch (Exception ex) {
                    System.out.println(ex);
                }
            }
        }).start();
    }
    public static void main(String[] args) {
        ReadMP3Files mp3 = new ReadMP3Files ("Full_Metal.mp3");
        mp3.play();
        //Lam gi do trong thoi gian phat nhac
    }
}